<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <button id="btn">节流提交</button>

</body>
<script>

    function success() {
        console.log('节流提交')
    }

    throttle = (fun,delay) => {
        let flag = true;
        return () => {
            if(!flag) return 
            flag = false;
            setTimeout(() => {
                fun();
                flag = true
            },delay)
        }
    }


    const oThrottle = throttle(success,2000);

    const btn = document.getElementById("btn");
    btn.addEventListener("click",oThrottle)
</script>
</html>